package com.tuniu.agents.tools.widgets;

import com.tuniu.agents.tools.widgets.tool.RestaurantListTool;
import com.tuniu.agents.tools.widgets.tool.WeatherListTool;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Description;

@Configuration
@EnableConfigurationProperties(WidgetsProperties.class)
@ConditionalOnClass(WidgetsProperties.class)
@ConditionalOnProperty(prefix = "aigc.agents.tools.widgets", name = "enabled", havingValue = "true")
public class WidgetsAutoConfiguration {

    @Bean(WeatherListTool.TOOLNAME)
    @ConditionalOnMissingBean
    @Description("Weather inquiry, check weather information based on city name.")
    @Tool(returnDirect = true)
    public WeatherListTool weatherListTool(WidgetsProperties properties) {
        return new WeatherListTool(properties);
    }

    @Bean(RestaurantListTool.TOOLNAME)
    @ConditionalOnMissingBean
    @Description("Restaurant recommendation, recommend related restaurants based on location name or coordinates.")
    @Tool(returnDirect = true)
    public RestaurantListTool restaurantListTool(WidgetsProperties properties) {
        return new RestaurantListTool(properties);
    }
}
